package eteam.aps.controller;

import eteam.aps.common.R;
import eteam.aps.common.exceptions.AuthException;
import eteam.aps.service.QueryInfoService;
import eteam.aps.systeminterface.model.vo.QueryInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 查询信息控制层
 *
 * @author WMT
 * @Date 2023/2/3 15:11
 */
@Api(tags = "查询信息模块")
@RestController
public class QueryInfoController implements IQueryInfoController{

    @Autowired
    private QueryInfoService queryInfoService;

    @Autowired
    private RedisTemplate<String,String> redisTemplate;

    /**
     * 查询用户信息
     * @return 用户id,name
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/selectUsername")
    public Map<String, String> selectUserName() throws Exception, AuthException {
        return queryInfoService.selectUserName();
    }

    /**
     * 查询机构信息
     * @return 机构id,name
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/selectOrgname")
    public Map<String, String> selectOrgName() throws Exception, AuthException {
        return queryInfoService.selectOrgName();
    }

    /**
     * 查询机构编号
     * @return 机构编号
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/selectOrgCode")
    public Map<String, String> selectOrgCode() throws Exception, AuthException {
        return queryInfoService.selectOrgCode();
    }

    /**
     * 查询保障机构信息
     * @return 保障机构id,name
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/selectProOrgname")
    public Map<String, String> selectProOrgName() throws Exception, AuthException {
        return queryInfoService.selectProOrgName();
    }

    /**
     * 查询字典信息
     * @return 字典id,name
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/selectDdName")
    public Map<String, String> selectDdName() throws Exception, AuthException {
        return queryInfoService.selectDdName();
    }

    /**
     * 查询仓库信息
     * @return 仓库id,name
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/selectDepotName")
    public Map<String, String> selectDepotName() throws Exception, AuthException {
        return queryInfoService.selectDepotName();
    }

    /**
     * 查询费用类型信息
     * @return 费用类型id,name
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/selectFundName")
    public Map<String, String> selectFundName() throws Exception, AuthException {
        return queryInfoService.selectFundName();
    }

    /**
     * 查询保养等级信息
     * @return 保养等级id,name
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/selectPreserveLevelName")
    public Map<String, String> selectPreserveLevelName() throws Exception, AuthException {
        return queryInfoService.selectPreserveLevelName();
    }

    /**
     * 查询巡修等级信息
     * @return 巡修等级id,name
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/selectRepairsLevelName")
    public Map<String, String> selectRepairsLevelName() throws Exception, AuthException {
        return queryInfoService.selectRepairsLevelName();
    }

    /**
     * 查询维修等级信息
     * @return 维修等级id,name
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/selectRepairName")
    public Map<String, String> selectRepairName() throws Exception, AuthException {
        return queryInfoService.selectRepairName();
    }


    /**
     * 查询字典列表
     * @return 字典列表
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/ddList")
    public R<List<QueryInfoVo>> dictionaryList() throws Exception, AuthException {
        return R.success(queryInfoService.dictionaryList());
    }


    @Override
    @PostMapping("/ed/maintainPlanList")
    public R<List<QueryInfoVo>> maintainPlanList() throws Exception, AuthException {
        return R.success(queryInfoService.maintainPlanList());
    }

    /**
     * 根据机构id查询人员列表
     * @param fOrgId 机构id
     * @return 人员列表
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/personList/{fOrgId}")
    public R<List<QueryInfoVo>> personList(@PathVariable String fOrgId) throws Exception, AuthException {
        return R.success(queryInfoService.personList(fOrgId));
    }

    /**
     * 查询人员列表
     * @return 人员列表
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/userList")
    public R<List<QueryInfoVo>> userList() throws Exception, AuthException {
        return R.success(queryInfoService.userList());
    }

    /**
     * 查询巡修等级列表
     * @return 巡修等级列表
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/preserveLevelList")
    public R<List<QueryInfoVo>> preserveLevelList() throws Exception, AuthException {
        return R.success(queryInfoService.preserveLevelList());
    }

    /**
     * 查询保养等级列表
     * @return 保养等级列表
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/patrolsRepairsList")
    public R<List<QueryInfoVo>> patrolsRepairsList() throws Exception, AuthException {
        return R.success(queryInfoService.patrolsRepairsList());
    }

    /**
     * 查询维修等级列表
     * @return 维修等级列表
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/repairList")
    public R<List<QueryInfoVo>> repairList() throws Exception, AuthException {
        return R.success(queryInfoService.repairList());
    }

    /**
     * 查询机构列表
     * @return 机构列表
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/orgList")
    public R<List<QueryInfoVo>> orgList() throws Exception, AuthException {
        return R.success(queryInfoService.orgList());
    }

    /**
     * 查询保障机构列表
     * @return 保障机构列表
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/proOrgList")
    public R<List<QueryInfoVo>> proOrgList() throws Exception, AuthException {
        return R.success(queryInfoService.proOrgList());
    }

    /**
     * 查询仓库列表
     * @return 仓库列表
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/depotList")
    public R<List<QueryInfoVo>> depotList() throws Exception, AuthException {
        return R.success(queryInfoService.depotList());
    }

    /**
     * 查询生产商列表
     * @return 生产商列表
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @PostMapping("/ed/producerList")
    public R<List<QueryInfoVo>> producerList() throws Exception, AuthException {
        return R.success(queryInfoService.producerList());
    }

    /**
     * 查询型号列表
     * @return 型号列表
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @ApiOperation("型号列表")
    @PostMapping("/ed/modelList")
    public R<List<QueryInfoVo>> modelList() throws Exception, AuthException {
        return R.success(queryInfoService.modelList());
    }

    /**
     * 查询单位列表
     * @return 单位列表
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @ApiOperation("单位列表")
    @PostMapping("/ed/unitList")
    public R<List<QueryInfoVo>> unitList() throws Exception, AuthException {
        return R.success(queryInfoService.unitList());
    }

    /**
     * 根据字典分类名称查询对应的字典id,name
     * @param ddcName 字典分类名称
     * @return 字典id,name
     * @throws Exception
     * @throws AuthException
     */
    @Override
    @ApiOperation("查询字典信息")
    @PostMapping("/ed/selectDdInfo")
    public R<List<QueryInfoVo>> selectDdInfo(@RequestParam("ddcName") String ddcName) throws Exception, AuthException {
        return R.success(queryInfoService.selectDdInfo(ddcName));
    }
}
